<template>
    <view-box style="background:#F3F6F7;">
      <div style="height:10px;"></div>
      <div class="border-priva">
        <div class="prica-clas">
            <p style="padding-left:10px;">评估</p>
        </div>
        <div class="border-privac">
            <check-icon :value.sync="comseo.is_assess_psychology">我的心理学评估是否对外显示</check-icon>
        </div>
        <div class="border-privac">
            <check-icon :value.sync="comseo.is_assess_yijing">我的易经评估是否对外显示</check-icon>
        </div>
      </div>
      <div style="height:10px;"></div>
      <div class="border-priva">
        <div class="prica-clas">
            <p style="padding-left:10px;">性别</p>
        </div>
        <div class="border-privac">
            <check-icon :value.sync="comseo.is_sex">性别是否对外显示</check-icon>
        </div>
      </div>

      <div class="button-priva">
          <button style="background:#32B6C6;border:1px solid #32B6C6;" @click="updata">保存</button>
      </div>
    </view-box>
</template>
<script>
import { ViewBox, Box, Flexbox, FlexboxItem, Group, Cell, CellBox, XHeader, CheckIcon } from 'vux'
export default {
  components: {
    ViewBox,
    Box,
    Flexbox,
    Group,
    Cell,
    CellBox,
    FlexboxItem,
    XHeader,
    CheckIcon
  },
  data () {
    return {
      labelPosition: false,
      labelPosition1: false,
      comseo: {},
      data: []
    }
  },
  mounted () {
    this.myPrivac()
  },
  methods: {
    change (val, label) {
      console.log('change', val, label)
    },
    myPrivac () {
      this.$http.get('/myPrivac').then(response => {
        let item = response.data
        let obj = {
          is_assess_psychology: Boolean(item.is_assess_psychology),
          is_assess_yijing: Boolean(item.is_assess_yijing),
          is_sex: Boolean(item.is_sex)
        }
        this.data.push(obj)
        this.comseo = this.data[0]
        console.log(this.comseo)
      }).catch(error => {
        console.log(error)
      })
    },
    updata () {
      var isassesspsychology = ''
      if (this.comseo.is_assess_psychology === true) {
        isassesspsychology = 1
      } else {
        isassesspsychology = 0
      }
      var isassessyijing = ''
      if (this.comseo.is_assess_yijing === true) {
        isassessyijing = 1
      } else {
        isassessyijing = 0
      }
      var issex = ''
      if (this.comseo.is_sex === true) {
        issex = 1
      } else {
        issex = 0
      }
      let data = {
        is_assess_psychology: isassesspsychology,
        is_assess_yijing: isassessyijing,
        is_sex: issex
      }
      this.$http.put('/myPrivac/update', data).then(response => {
        this.$vux.toast.show({
          text: response.data.message,
          type: 'text'
        })
        this.$router.push({ path: '/myPage' })
        console.log(response)
      }).catch(error => {
        console.log(error)
      })
    }
  }
}
</script>
<style scoped>
.background-cl{
    background: #fff;
}
  .prica-clas{
      width: 100%;
      border-bottom: 1px solid #f4f4f4;
      height: 50px;
      line-height: 50px;
      font-size: 15px;
  }
 .border-privac{
     width: 96%;
     border-bottom: 1px solid #f4f4f4;
     line-height: 40px;
     margin-left: 4%;
     height: 40px;
     
 }
 .button-priva{
     width: 100%;
     position: fixed;
     bottom: 0px;
 }
 .button-priva button{
     width: 100%;
     height: 40px;
     background: #de3c3d;
     border-radius: 0px;
     border: 1px solid #de3c3d;
     font-size: 17px;
     color: #fff;
 }
 .border-priva{
   width:92%;
   margin-left: 4%;
   border-radius: 7px;
   background:#fff;
 }
</style>
<style>
    .vux-label{
        font-size: 14px !important;
    }
    .weui-cell__ft{
        font-size: 14px;
    }
    .weui-cell_access{font-size: 14px;}
    .vux-check-icon > .weui-icon-success:before, .vux-check-icon > .weui-icon-success-circle:before {
    color: #32B6C6!important;
    }
</style>